Title: Python tutorial - Automate the Boring Stuff

Q: >>> 5 + 3
A: 8

Q: >>> 7 - 4
A: 3

Q: >>> 3 + 5.0
A: 8.0

Q: >>> 5.5 * 2
A: 11.0

Q: What is the type of 8
A: int (integer)

Q: Something of type int
A: -1, 0, 1, 2, 3, 4, etc

Q: What is the type of 4.0
A: float (floating point number, or decimal)

Q: Something of type float
A: -3.78, 4.0, 3.2466, etc

Q: >>> 10 / 2
A: 5

Q: >>> 7 / 2
A: 3.5

Q: What is the type of "blah"
A: str (string)

Q: Something of type str
A: "this is a string", 'this is another string'

Q: >>> 'hello' * 2
A: 'hellohello'

Q: >>> 'world ' + 'hello'
A: 'world hello'

Q: >>> blah = 50
>>> blah
A: 50

Q: What code creates a variable called test with a value of 49?
A: >>> test = 49

Q: What code creates a variable called test_str with a value of 'test string'?
A: >>> test_str = 'test string'

Q: >>> x = 'foo'
>>> y = 'bar'
>>> x + ' ' + y
A: 'foo bar'

Q: >>> x = 'foo'
>>> y = 'bee'
>>> x + '' + '' + y
A: 'foobee'

Q: What does the print function do?
A: It takes an input of any type and prints it to the screen

Q: >>> print(5)
A: 5

Q: >>> print('this is a test')
A: this is a test

Q: >>> print(5 + 3 + 1)
A: 9

Q: >>> print('one' + 'two' * 2)
A: onetwotwo

Q: What does the len function do when given a string?
A: It returns how many characters are in the string, as an int.

Q: >>> len('first')
A: 5

Q: >>> len('f' + 'ir' + 's')
A: 4

Q: What does the input function do?
A: It gets input from the user and returns it as a string.

Q: >>> x = input()
50
>>> x
A: '50'

Q: What does the int function do?
A: It tries to turn things into ints (integers) and throws an error (exception) if it can't.

Q: >>> int('500')
A: 500

Q: >>> int('-123')
A: -123

Q: >>> int('50.4')
A: Python throws an exception

Q: What does the float function do?
A: It tries to turn things into floats (decimals) and throws an error (exception) if it can't.

Q: >>> float("50.5")
A: 50.5

Q: >>> float('5')
A: 5.0

Q: What does the str function do?
A: It tries to turn things into strings (ie things of type str).

Q: >>> str(500)
A: '500'

Q: >>> str(5.0)
A: '5.0'

Q: str('string')
A: 'string'